﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace Data_Access_Layer
{
    public sealed class Connection
    {
        private static Connection instance = null;
        private static SqlConnection con;

        private Connection()
        {
            string str = Properties.Settings.Default.ConnectionString;
            try
            {
                con = new SqlConnection(str);
            }
            catch(SqlException sqlException)
            {
                throw sqlException;
            }
            catch(Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
        public SqlConnection GetConnection()
        {
            return con;
        }
        public static Connection GetInstance()
        {
            if (instance == null)
            {
                instance = new Connection();
            }
            return instance;
        }
    }
}
